package com.cwj.servlet.listener;

import common.utils.IPUtil;
import org.springframework.boot.web.context.WebServerInitializedEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

import java.net.UnknownHostException;

@Component
public class ServletListener implements ApplicationListener<WebServerInitializedEvent> {

    @Override
    public void onApplicationEvent(WebServerInitializedEvent event) {
        try {

            System.out.println("项目启动成功 ip地址:http://"+ IPUtil.getLocalHostLANAddress().getHostAddress()+":"+event.getWebServer().getPort()+"/"+event.getApplicationContext().getApplicationName());
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
    }
}
